package org.poptest.util;

import org.poptest.testng.Assert;

/**
 * @author Alan Roche
 *         Date: 22/01/11
 *         Time: 00:10
 */
public final class AssertInternal {
    public static void notNull(final Object object, final String message) {
        isTrue(object != null, message);
    }

    public static void noneNull(final Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            AssertInternal.notNull(objects[i], "Object with index [" + i + "] is null.");
        }
    }

    public static void isTrue(final boolean expression, final String message) {
        if (!expression) {
            throw new IllegalStateException(message);
        }
    }

    public static void isInstance(final Object object, final Class<?> clazz) {
        isTrue(clazz.isInstance(object), "Object [" + object.getClass().getName() + "] is not an instance of " + clazz);
    }
}
